//
//  PdfHomeSigleView.m
//  PdfChange
//
//  Created by 蓝鳍互娱 on 2024/7/25.
//

#import "PdfHomeSigleView.h"
@interface PdfHomeSigleView()
@property (nonatomic,strong) UIImageView *pdfHomeSigleImgView;
@property (nonatomic,strong) UILabel *pdfHomeSigleLab;
@end
@implementation PdfHomeSigleView
-(instancetype)init{
    if (self == [super init]) {
        [self creatPdfSubView];
    }
    return self;
}
- (void)creatPdfSubView{
    self.pdfHomeSigleImgView = [[UIImageView alloc] init];
    [self addSubview:self.pdfHomeSigleImgView];
    [self.pdfHomeSigleImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(@(PdfRatio(0)));
        make.width.equalTo(@(PdfRatio(80)));
        make.height.equalTo(@(PdfRatio(80)));
    }];
    self.pdfHomeSigleLab = [[UILabel alloc] init];
    self.pdfHomeSigleLab.font = [UIFont systemFontOfSize:PdfRatio(24) weight:UIFontWeightRegular];
    self.pdfHomeSigleLab.textColor = PdfHex(@"#333333");
    self.pdfHomeSigleLab.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.pdfHomeSigleLab];
    [self.pdfHomeSigleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.pdfHomeSigleImgView.mas_bottom).offset(PdfRatio(10));
        make.height.equalTo(@(PdfRatio(34)));
    }];
    UIButton * pdfHomeSigleBtn = [[UIButton alloc] init];
    [pdfHomeSigleBtn addTarget:self action:@selector(pdfHomeSigle) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:pdfHomeSigleBtn];
    [pdfHomeSigleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(PdfRatio(0)));
    }];
}
-(void)setPdfHomeSigleType:(PdfHomeSigleType)pdfHomeSigleType{
    _pdfHomeSigleType = pdfHomeSigleType;
    if(_pdfHomeSigleType == PdfHomeSigleTypeWorld) {
        self.pdfHomeSigleImgView.image = PdfImageNamed(@"pdfHomeWord");
        self.pdfHomeSigleLab.text = @"Word";
    }else if(_pdfHomeSigleType == PdfHomeSigleTypeExcel) {
        self.pdfHomeSigleImgView.image = PdfImageNamed(@"pdfHomeExcel");
        self.pdfHomeSigleLab.text = @"Excel";
    }else if(_pdfHomeSigleType == PdfHomeSigleTypePpt) {
        self.pdfHomeSigleImgView.image = PdfImageNamed(@"pdfHomePpt");
        self.pdfHomeSigleLab.text = @"PPT";
    }else if(_pdfHomeSigleType == PdfHomeSigleTypeTxt) {
        self.pdfHomeSigleImgView.image = PdfImageNamed(@"pdfHomeTxt");
        self.pdfHomeSigleLab.text = @"TXT";
    }
}
- (void)pdfHomeSigle{
    if (self.TapHomeTypeBlock) {
        self.TapHomeTypeBlock(_pdfHomeSigleType);
    }
}
@end
